﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net.Sockets;
using System.Net;
using AMatysiak.Web;

namespace AMatysiakTest.Web
{
    [TestClass]
    public class IPTest
    {
        [TestMethod]
        public void getIPEndPoint()
        {
            TcpListener listener = new TcpListener(IPAddress.Loopback, 5555);
            listener.Start();

            TcpClient client = new TcpClient("127.0.0.1", 5555);
            IPAddress ip = client.GetIPEndPoint();

            Assert.AreEqual(IPAddress.Loopback, ip);

            listener.Stop();
        }

        [TestMethod]
        public void getPortEndPoint()
        {
            TcpListener listener = new TcpListener(IPAddress.Loopback, 5555);
            listener.Start();

            TcpClient client = new TcpClient("127.0.0.1", 5555);
            int port = client.GetPortEndPoint();

            Assert.AreEqual(5555, port);

            listener.Stop();
        }
    }
}
